package portal.pubcontroller.modules;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import net.sf.json.JSONObject;
import portal.pub.util.pf.Result;
import portal.pubitf.modules.pf.IASService;
import portal.pubitf.modules.pf.ISupplierService;
import portal.pubvo.system.UserVo;

@Controller
@SuppressWarnings("all")
public class SupplierController {

	@Resource(name = "aSServiceImpl")
	private IASService asSercive;

	@Resource(name = "supplierServiceImpl")
	private ISupplierService supplierService;

	//查询列表
	@RequestMapping(value = "/modules/supplier/asList")
	public void asList(HttpServletRequest request, HttpServletResponse response,HttpSession httpSession,
			@RequestParam(defaultValue="")String p_name,@RequestParam(defaultValue="")String c_name) {
		try {
			int page = Integer.valueOf(request.getParameter("page"));
			int limit = Integer.valueOf(request.getParameter("limit"));
			UserVo user = (UserVo) httpSession.getAttribute("user");
			if(user==null)throw new Exception("session已过期");

			//查询列表
			Result result = asSercive.getAllByWhere(page,limit,p_name,c_name);

			//结果返回
			response.setContentType("text/html;charset=utf-8");
			JSONObject json = new JSONObject();
			json.put("status", "0");
			response.getWriter().println(result.getJson());
		} catch (Exception e) {
			e.getStackTrace();
		}
	}
	//查询列表
	@RequestMapping(value = "/modules/supplier/supplierList")
	public void supplierList(HttpServletRequest request, HttpServletResponse response,
			@RequestParam(defaultValue="")String p_name,@RequestParam(defaultValue="")String c_name) {
		try {
			int page = Integer.valueOf(request.getParameter("page"));
			int limit = Integer.valueOf(request.getParameter("limit"));

			//查询列表
			Result result = asSercive.getAllByWhere(page,limit,p_name,c_name);

			//结果返回
			response.setContentType("text/html;charset=utf-8");
			JSONObject json = new JSONObject();
			json.put("status", "0");
			response.getWriter().println(result.getJson());
		} catch (Exception e) {
			e.getStackTrace();
		}
	}
}
